package com.c.ctgproject.ui.files

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.c.ctgproject.base.BaseViewModel
import com.c.ctgproject.http.ApiMethods
import com.c.ctgproject.utils.MyLog
import com.c.ctgproject.utils.awaitSync
import com.c.ctgproject.utils.launch
import com.c.ctgproject.utils.userToken

class FileFirstExamineViewModel : BaseViewModel() {
    private val mResult = MutableLiveData<String>()
    val result: LiveData<String> get() = mResult

    private val mCarResult = MutableLiveData<String>()
    val carResult: LiveData<String> get() = mCarResult

    fun getCarList(page: Int, size: Int, searchText: String) {
        launch {
            MyLog.d("搜索内容:$searchText")
            mResult.value = ApiMethods.getApiService().getFirstCarList(userToken, page, size, searchText).awaitSync()
        }
    }

    fun getFirstExamineCarByCarPlate(carPlate: String) {
        launch {
            mCarResult.value = ApiMethods.getApiService().getFirstExamineCarByCarPlate(userToken, carPlate).awaitSync()
        }
    }

}